<template>
    <Page class="basic company">
        <template #header>
            <el-input v-model="params.villageName" placeholder="请输入项目名称" maxlength="50" />
            <!-- <el-input v-model="params.orgName" placeholder="请输入所属公司" /> -->
            <el-button class="ed-button ed_black-bottom"  @click="search()"><svg-icon icon-class="search-svg"/>查询</el-button>
            <el-button class="ed-button ed_white_bottom" @click="reset()"><svg-icon icon-class="reset-svg"/>重置</el-button>
        </template>
        <PageCard title="物业项目管理">
            <template #actions>
                <el-button class="ed-button ed_black-bottom ed-button36" @click="add()" v-has="'basic:project:add'"><svg-icon icon-class="add-svg"/>添加物业项目</el-button>
            </template>
            <ApiTable :api="tableApi" ref="table" :params="params">
                <el-table-column type="index" width="80" label="序号"></el-table-column>
                <el-table-column :show-overflow-tooltip="true" prop="villageName" label="项目名称"></el-table-column>
                <el-table-column :show-overflow-tooltip="true" prop="orgName" label="所属公司"></el-table-column>
                <el-table-column :show-overflow-tooltip="true" prop="makeTime" label="创建时间" :formatter="formatDate"></el-table-column>
                <el-table-column :show-overflow-tooltip="true" label="操作">
                    <template slot-scope="scope">
                        <el-button class="ed-table-bottom ed_black_border" v-has="'basic:project:update'" @click="edit(scope.row)">编辑</el-button>
                        <el-button class="ed-table-bottom ed_blue_border" v-has="'basic:project:config'" @click="configure(scope.row)">基础配置</el-button>
                        <el-button class="ed-table-bottom ed_green_border" v-has="'basic:project:config'" @click="deviceConfigure(scope.row)">设备配置</el-button>
                    </template>
                </el-table-column>
            </ApiTable>
        </PageCard>
        <ed-confirm-delete ref="confirmDeleteRef" @confirmDeleteTrue="confirmDeleteTrue()"></ed-confirm-delete>
        <!-- <ed-export :dataApi="dataApi" v-if="isEdExport" @exportSuccess="exportSuccess"></ed-export> -->
    </Page>
     
</template>

<script>
import EdExport from "src/components/EdExport.vue";
import {projectList,delMerchant} from "./api.js";
import Page from '../../components/Page.vue'
import PageCard from 'src/views/components/PageCard.vue'
import ApiTable from 'src/components/ApiTable.vue'
import EdSelect from 'src/components/EdSelect.vue'
import EdDialog from 'src/components/EdDialog.vue'
import { defineComponent } from 'vue'
import EdConfirmDelete from "src/components/EdConfirmDelete.vue";
export default defineComponent({
    name: 'project',
    components: { Page, PageCard, ApiTable, EdSelect, EdDialog,EdConfirmDelete,EdExport},
    data() {
        return {
            params: {
                villageName:'',
                orgName:"",
                makeTime:''
            },
            confirmRow: '',
            showCode:false,
        }
    },
    activated(){
        this.$nextTick(()=>{
                this.$refs.table.load(1)
                // this.initDic()
            })
    },
    methods: {
        tableApi:projectList,
        search(){
            this.$refs.table.load(1)
        },
        reset(){
            this.params = {
                villageName:'',
                orgName:"",
            };
            this.$nextTick(()=>{
                this.$refs.table.load(1,10)
                })
            },
        add(){
            this.$router.push({
                path: '/basic/project-add'
            })
        },
        edit(row){
            this.$router.push({
                path: '/basic/project-update',
                query: {id:row.villageId,entranceManufacturer:row.entranceManufacturer}
            })
        },
        // 配置
        configure(row){
            this.$router.push({
                path: '/basic/project-configure',
                query: {villageId: row.villageId, villageName:row.villageName}
            })
        },
        formatDate(row, column) {
                // 获取单元格数据
                let date = row[column.property];
                if (date) {
                    return this.transformDate(date)
                } else {
                    return ''
                }
            },
            //标准时间格式转yyyy-MM-dd HH:mm:ss
            transformDate(date) {
                if (date) {
                    let dt = new Date(date);
                    return dt.getFullYear() + '-' +
                        ((dt.getMonth() + 1) < 10 ? ('0' + (dt.getMonth() + 1)) : (dt.getMonth() + 1)) + '-' +
                        (dt.getDate() < 10 ? ('0' + dt.getDate()) : dt.getDate()) + ' ' +
                        (dt.getHours() < 10 ? ('0' + dt.getHours()) : dt.getHours()) + ':' +
                        (dt.getMinutes() < 10 ? ('0' + dt.getMinutes()) : dt.getMinutes()) 
                        // (dt.getSeconds() < 10 ? ('0' + dt.getSeconds()) : dt.getSeconds())
                } else {
                    return ''
                }
            },
        // 设备配置
        deviceConfigure(row){
            this.$router.push({
                path: '/basic/project-deviceConfigure',
                query: {villageId: row.villageId, villageName:row.villageName}
            })
        }
    }
})
</script>

<style lang="scss" scoped>
.erweicodeCenter{
    display: flex;
    justify-content: center;
    align-items: center;
}
</style>